{% extends 'myadmin/index.html' %}

{% block title %}
<title>后台-订单列表</title>
{% endblock %}

{% block con %}

<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title  am-cf">订单列表</div>
                </div>

                <div class="widget-body  am-fr">
                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                        <div class="am-form-group">
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                   
                                </div>
                            </div>
                        </div>
                    </div>
                <!-- form表单不写提交地址默认提交到本页面　默认就是get提交方式 -->
               <form>
                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                        <div class="am-form-group tpl-table-list-select">
                            <select name="types" data-am-selected="{btnSize: 'sm'}" style="display: none;">
                              <option value="shouhuoren" {% if request.GET.types == 'shouhuoren' %} selected {% endif %}>收货人</option>
                              <option value="shouhuophone" {% if request.GET.types == 'shouhuophone' %} selected {% endif %}>收货电话</option>
                              <option value="shouhuoaddress" {% if request.GET.types == 'shouhuoaddress' %} selected {% endif %}>收货地址</option>
                              <option value="status" {% if request.GET.types == 'status' %} selected {% endif %}>状态</option>
                            </select>
                        </div>
                    </div>
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                        <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                            <input name='keywords' type="text" class="am-form-field ">
                            <span class="am-input-group-btn">
                                <button id='search' class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search"></button>
                            </span>
                        </div>
                    </div>
                </form>



                    <div class="am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
                            <thead>
                                <tr>
                                    <th>订单号</th>
                                    <th>收货人</th>
                                    <th>收货电话</th>
                                    <th>收货地址</th>
                                    <th>支付</th>
                                    <th>总价</th>
                                    <th>订单生成时间</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for i in orderslist %}
                                <tr>
                                    <td>{{i.id}}</td>
                                    <td class="am-text-middle">{{ i.shouhuoren }}</td> 
                                    <td class="am-text-middle">{{ i.shouhuophone }}</td>
                                    <td class="am-text-middle">{{ i.shouhuoaddress }}</td>
                                    <td class="am-text-middle">{{ i.buytype }}</td>
                                    <td class="am-text-middle">{{ i.totalprice }}</td> 
                                    <td class="am-text-middle">{{ i.addtime }}</td> 
                                    <td class="am-text-middle">
                                    <select style="color:#000" class="status" oid="{{i.id}}">
                                        <option value="0" {% if i.status == 0 %} selected {% endif %}>未支付</option>
                                        <option value="1" {% if i.status == 1 %} selected {% endif %}>待发货</option>
                                        <option value="2" {% if i.status == 2 %} selected {% endif %}>待收货</option>
                                        <option value="3" {% if i.status == 3 %} selected {% endif %}>待评价</option>

                                    </select>
                                    </td> 
                                    
                                   <td class="am-text-middle">
                                    <div class="tpl-table-black-operation">
                                        
                                        <a href="{% url 'myadmin_indexinfo'%}?oid={{i.id}}" class="tpl-table-black-operation-del">
                                             查看订单详情
                                        </a>
                                    </div>
                                </td>


                                </tr>
                                {% endfor %}
                                <!-- more data -->
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr">
                            <ul class="am-pagination tpl-pagination">
                               
                                {% load pagetag %}

                                <!-- requset 请求对象　num_pages显示的总页数 -->
                                {% Showpages orderslist.paginator.num_pages request %}


                                
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $('.status').change(function(){
        // 获取该商品的订单id
        var oid = $(this).attr('oid')
        // 获取选择的状态值
        var status = $(this).val()
        // console.log(oid,status)
        // 发送ajax请求
        $.get('{% url 'myadmin_statusedit' %}',{'oid':oid,'status':status},function(data){
            if(data['error']==0){
                alert(data['msg'])
            }
        },'json')})

</script>


{% endblock %}